package com.alibam.core.wechat.pay;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import com.alibam.core.wechat.util.PayUtils;

@XmlRootElement(name = "xml")
public class PayRequest {

	private String appid;
	private String mch_id;
	private String device_info;
	private String nonce_str;
	private String sign;
	private String body;
	private String detail;
	private String attach;
	private String out_trade_no;
	private String fee_type;
	private String total_fee;
	private String spbill_create_ip;
	private String time_start;
	private String time_expire;
	private String goods_tag;
	private String notify_url;
	private String trade_type;
	private String product_id;
	private String limit_pay;
	private String openid;

	public PayRequest() {
	}

	public PayRequest(String appid, String mch_id, String device_info,
			String nonce_str, String sign, String body, String detail,
			String attach, String out_trade_no, String fee_type,
			String total_fee, String spbill_create_ip, String time_start,
			String time_expire, String goods_tag, String notify_url,
			String trade_type, String product_id, String limit_pay,
			String openid) {
		super();
		this.appid = appid;
		this.mch_id = mch_id;
		this.device_info = device_info;
		this.nonce_str = nonce_str;
		this.sign = sign;
		this.body = body;
		this.detail = detail;
		this.attach = attach;
		this.out_trade_no = out_trade_no;
		this.fee_type = fee_type;
		this.total_fee = total_fee;
		this.spbill_create_ip = spbill_create_ip;
		this.time_start = time_start;
		this.time_expire = time_expire;
		this.goods_tag = goods_tag;
		this.notify_url = notify_url;
		this.trade_type = trade_type;
		this.product_id = product_id;
		this.limit_pay = limit_pay;
		this.openid = openid;
	}

	/**
	 * 微信支付请求， 传入必要的参数， 其他自动生成。
	 * 
	 * @param openId
	 *            openid
	 * @param orderId
	 *            订单编号
	 * @param orderBody
	 *            订单内容
	 * @param money
	 *            订单金额，单位为分。
	 * @param ip
	 *            订单创建ip
	 */
	public PayRequest(String openId, String orderId, String orderBody,
			String money, String ip) {
		this.openid = openId;
		this.out_trade_no = orderId;
		this.body = orderBody;
		this.total_fee = money;
		this.spbill_create_ip = ip;

		// Auto create attr.
		this.setNonce_str(PayUtils.createNoncestr());
		this.setFee_type("CNY");
		this.setTrade_type("JSAPI");
	}

	@XmlElement(name = "appid")
	public String getAppid() {
		return appid;
	}

	public void setAppid(String appid) {
		this.appid = appid;
	}

	@XmlElement(name = "mch_id")
	public String getMch_id() {
		return mch_id;
	}

	public void setMch_id(String mch_id) {
		this.mch_id = mch_id;
	}

	@XmlElement(name = "device_info")
	public String getDevice_info() {
		return device_info;
	}

	public void setDevice_info(String device_info) {
		this.device_info = device_info;
	}

	@XmlElement(name = "nonce_str")
	public String getNonce_str() {
		return nonce_str;
	}

	public void setNonce_str(String nonce_str) {
		this.nonce_str = nonce_str;
	}

	@XmlElement(name = "sign")
	public String getSign() {
		return sign;
	}

	public void setSign(String sign) {
		this.sign = sign;
	}

	@XmlElement(name = "body")
	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	@XmlElement(name = "detail")
	public String getDetail() {
		return detail;
	}

	public void setDetail(String detail) {
		this.detail = detail;
	}

	@XmlElement(name = "attach")
	public String getAttach() {
		return attach;
	}

	public void setAttach(String attach) {
		this.attach = attach;
	}

	@XmlElement(name = "out_trade_no")
	public String getOut_trade_no() {
		return out_trade_no;
	}

	public void setOut_trade_no(String out_trade_no) {
		this.out_trade_no = out_trade_no;
	}

	@XmlElement(name = "fee_type")
	public String getFee_type() {
		return fee_type;
	}

	public void setFee_type(String fee_type) {
		this.fee_type = fee_type;
	}

	@XmlElement(name = "total_fee")
	public String getTotal_fee() {
		return total_fee;
	}

	public void setTotal_fee(String total_fee) {
		this.total_fee = total_fee;
	}

	@XmlElement(name = "spbill_create_ip")
	public String getSpbill_create_ip() {
		return spbill_create_ip;
	}

	public void setSpbill_create_ip(String spbill_create_ip) {
		this.spbill_create_ip = spbill_create_ip;
	}

	@XmlElement(name = "time_start")
	public String getTime_start() {
		return time_start;
	}

	public void setTime_start(String time_start) {
		this.time_start = time_start;
	}

	@XmlElement(name = "time_expire")
	public String getTime_expire() {
		return time_expire;
	}

	public void setTime_expire(String time_expire) {
		this.time_expire = time_expire;
	}

	@XmlElement(name = "goods_tag")
	public String getGoods_tag() {
		return goods_tag;
	}

	public void setGoods_tag(String goods_tag) {
		this.goods_tag = goods_tag;
	}

	@XmlElement(name = "notify_url")
	public String getNotify_url() {
		return notify_url;
	}

	public void setNotify_url(String notify_url) {
		this.notify_url = notify_url;
	}

	@XmlElement(name = "trade_type")
	public String getTrade_type() {
		return trade_type;
	}

	public void setTrade_type(String trade_type) {
		this.trade_type = trade_type;
	}

	@XmlElement(name = "product_id")
	public String getProduct_id() {
		return product_id;
	}

	public void setProduct_id(String product_id) {
		this.product_id = product_id;
	}

	@XmlElement(name = "limit_pay")
	public String getLimit_pay() {
		return limit_pay;
	}

	public void setLimit_pay(String limit_pay) {
		this.limit_pay = limit_pay;
	}

	@XmlElement(name = "openid")
	public String getOpenid() {
		return openid;
	}

	public void setOpenid(String openid) {
		this.openid = openid;
	}

	@XmlTransient
	public String[] getCDataNode() {
		String[] cDataNodes = {attach , body, sign};
		return cDataNodes;
	}

}
